<template>
  <div>
    <NavHead>
      <template v-slot:iconfont-left>
        <i class="iconfont icon-arrowLeft arrow" @click="$router.back()"></i>
      </template>
      <template v-slot:title>
        <SearchInput :textDesc='textDesc1' />
      </template>
      <template v-slot:iconfont-right>
        <i class="iconfont icon-gouwuche point" @click="$router.push('/shopCar')"></i>
      </template>
    </NavHead>
    <div class="box">
      <div class="desc">
        <p>家用电器</p>
      </div>
      <div class="more">
        <p>更多</p>
      </div>
      <div class="list">
        <div class="pic" v-for="(item, index) in list" :key="index">
          <img :src="item.img" alt="" />
          <p>{{ item.title }}</p>
        </div>
      </div>
      <div class="desc">
        <p>家用家具</p>
      </div>
      <div class="more">
        <p>更多</p>
      </div>

      <div class="list">
        <div class="pic" v-for="(item1, index1) in list1" :key="index1">
          <img :src="item1.img" alt="" />
          <p>{{ item1.title }}</p>
        </div>
      </div>
      <div class="hot">
        <p>热门推荐</p>
      </div>
      <div class="list1">
        <div
          class="pic1"
          v-for="(item, index) in list2"
          :key="index"
          @click="jumpDetails(item.id)"
        >
          <img :src="item.img" alt="" />
          <p class="names">{{ item.name }}</p>
          <p class="price">¥ {{ item.price }}</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import api from "../../api";
import NavHead from "../../components/NavHead";
import SearchInput from "../../components/searchInput/SearchInput";

export default {
  name: "SecondHand",
  components: {
    NavHead,
    SearchInput,
  },
  data() {
    return {
      list: [],
      list1: [],
      list2: [],
      textDesc1:'搜索您想要的区域'
    };
  },
  mounted() {
    api.getHousehold().then((res) => {
      // console.log(res.data);
      this.list = res.data.list;
    });
    api.getFurniture().then((res) => {
      // console.log(res.data);
      this.list1 = res.data.list;
    });
    api
      .getHotTopic({
        id: this.list2.id,
      })
      .then((res) => {
        // console.log(res.data);
        this.list2 = res.data.list;
      });
  },
  methods: {
    jumpDetails(id) {
      console.log(id);
      this.$router.push({ name: "Details", params: { id } });
    },
  },
};
</script>

<style>
.box {
  background-color: #f5f5f5;
  height: 20rem;
  margin-top: 1.2rem;
}
.arrow {
  color: #fff;
  margin-top: 0.3rem;
}
.point {
  color: #fff;
  font-size: 0.5rem;
}
.title {
  font-size: 0.3rem;
  margin-top: 0.2rem;
  margin-bottom: 0.2rem;
  color: rgb(71, 67, 67);
}
.title {
  font-size: 0.32rem;
  margin-top: 0.2rem;
  margin-bottom: 0.2rem;
  color: rgb(71, 67, 67);
}
.list {
  background-color: white;
  height: 2.4rem;
  width: 95%;
  margin-left: 2.5%;
  border-radius: 1px solid #d3d3d3;
  display: flex;
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
  -webkit-box-shadow: #ccc 0px 0px 10px;
  -moz-box-shadow: #ccc 0px 0px 10px;
  box-shadow: #ccc 0px 0px 10px;
}
.list .pic img {
  height: 1.2rem;
  width: 1.2rem;
  margin-top: 0.6rem;
  margin-left: 0.5rem;
  border-radius: 50%;
  flex: 1;
}
.list .pic p {
  font-size: 0.26rem;
  padding-left: 0.4rem;
}
.desc {
  height: 0.4rem;
  width: 2rem;
  margin-top: 0.1rem;
  margin-bottom: 0.1rem;
  font-size: 0.28rem;
  float: left;
}

.more {
  height: 0.4rem;
  width: 2rem;
  margin-top: 0.1rem;
  margin-bottom: 0.1rem;
  font-size: 0.28rem;
  float: right;
}
.hot{
  margin-top: 0.2rem;
}
.hot p{
  font-size:0.32rem;
  text-align: left;
  margin-left: 0.3rem;
}
.list1 {
  display: flex;
  flex-wrap: wrap;
  height: 4rem;
  width: 98%;
  margin: 0 auto;
  box-sizing: border-box;
  padding: 0.1rem;
}
.list1 .pic1 {
  width: 47%;
  margin: 0.1rem;
  box-sizing: border-box;
  background-color: #fff;
}
.list1 .pic1:nth-child(2n + 1) {
  margin-left: 0;
}
.list1 .pic1:nth-child(2n) {
  margin-left: 0.15rem;
}

.list1 .pic1 img {
  width: 100%;
  height: 2.8rem;
}
.list1 .pic1 .names {
  font-size: 0.26rem;
  color: grey;
  text-align: left;
  padding-left: 0.2rem;
}
.list1 .pic1 .price {
  font-size: 0.24rem;
  color: red;
  text-align: left;
  padding-left: 0.2rem;
}
</style>